package com.touchstone.synchdata.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @Description : swagger配置
 * @Author : hunter
 * @Date: 2018-10-12 12:24
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    /**
     * 域名
     */
    @Value("${server.hostUrl}")
    private String hostUrl;

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .host(hostUrl)
                .select()
                //com.touchstone.pacs->包名
                .apis(RequestHandlerSelectors.basePackage("com.touchstone.synchdata.controller"))
                .paths(PathSelectors.any())
                .build()
                .apiInfo(apiInfo());
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("试金石软件-数据同步服务")
                .description("试金石软件-远程会诊数据同步API文档接口")
                .termsOfServiceUrl("")
                .version("2.0")
                .build();
    }
}
